#ifndef _WIDGET_H_
#define _WIDGET_H_

#include <stdint.h>
#include "list.h"

typedef struct list_head list_node_t;

typedef enum
{
    widget_type_none,
    widget_type_screen,
    widget_type_lable,
    widget_type_img,
    widget_type_bar,
    widget_type_tail_view,
    widget_type_max,
} widget_type_e;

typedef enum
{
    widget_state_none,
    widget_state_selected,
} widget_state_e;

typedef enum
{
    widget_event_none,
    widget_event_key,
} widget_event_e;

typedef enum
{
    keypad_event_none,
    keypad_event_enter,
    keypad_event_left,
    keypad_event_right,
    keypad_event_up,
    keypad_event_down,
} keypad_event_e;

typedef void (*widget_event_cb)(void *obj, int event, int event_val, void *user_data);
typedef void (*widget_render_func)(void* obj);

typedef struct
{
    list_node_t node; // 指向parent的node
    widget_type_e widget_type;
    widget_state_e state; // 状态
    int x, y, w, h;
    widget_event_cb event_cb;
    void *user_data;
} widget_t; //



typedef struct
{
    widget_t obj;
} may_screen_t;

void widget_init(void);
void widget_main_loop(void);
widget_t *widget_create(void);
void widget_set_pos(widget_t *obj, int x, int y);
void widget_set_size(widget_t *obj, int w, int h);
uint8_t widget_get_height(widget_t *obj);
uint8_t widget_get_width(widget_t *obj);
uint8_t widget_get_x(widget_t *obj);
uint8_t widget_get_y(widget_t *obj);

may_screen_t *screen_create(int w, int h);
widget_t *screen_get(void *obj);

#endif